#include <iostream>
#include "mQueue.h"

using namespace std;

int main() {
	int num=0,input=0;
	mQueue<int> q(3);
	for(;;)
	{
		cin >> input;
		switch (input) {
			case 1:
				q.push(num);
				break;
			case 2:
				cout << q.pop_FIFO() << endl;
				break;
			default:
				break;
		}
		num++;
	}
	return 0;
}